<?php
include('conect.php');

//connection String
$con = mysql_connect($hostname, $username, $password) or die('Could not connect: ' . mysql_error());
//select database
mysql_select_db($database, $con);

mysql_query("SET NAMES utf8");
$arr = array();

function getDT($da) {
	return date($da);
}
$query = "SELECT * FROM events";
	$rs = mysql_query($query);
	$grid = array();
	while($obj = mysql_fetch_object($rs)) {
		$grid[] = $obj;
	}
	$arr = array(
		'data'  => $grid
	);

	//$arr = array(
		///array('id' => 1001, 'cid' => 1, 'start' => getDT('2012-04-01 10:00:00'), 'end' => getDT('2012-04-21 23:00:00'), 'title' => 'Vacation', 'notes' => 'Have fun'),
        //array('id' => 1002, 'cid' => 2, 'start' => 'Mon Apr 02 2012 10:00:00 GMT+0200 (CEST)', 'end' => getDT('+13 hour'), 'title' => 'Lunch with Matt', 'loc' => 'Chuy\'s', 'url' => 'http://chuys.com', 'notes' => 'Order the queso'),
        //array('id' => 1003, 'cid' => 3, 'start' => $d2, 'end' => $d2, 'title' => 'Project due'),
        //array('id' => 1004, 'cid' => 1, 'start' => getDT(''), 'end' => getDT(''), 'title' => 'Sarah\'s birthday', 'ad' => true, 'notes' => 'Need to get a gift'),
        ///array('id' => 1005, 'cid' => 2, 'start' => getDT('2012-04-01 10:00:00'), 'end' => getDT('2012-04-21 23:00:00'), 'title' => 'A long one...', 'ad' => true),
        //array('id' => 1006, 'cid' => 3, 'start' => getDT('Tue Apr 10 2012 00:00:00'), 'end' => getDT('Tue May 01 2012 23:59:59'), 'title' => 'School holiday'),
        //array('id' => 1007, 'cid' => 1, 'start' => getDT('+9 hour'), 'end' => getDT('+9 hour +30 minute'), 'title' => 'Haircut', 'notes' => 'Get cash on the way', 'rem' => 60),
        //array('id' => 1008, 'cid' => 3, 'start' => getDT('-30 day'), 'end' => getDT('-28 day'), 'title' => 'An old event', 'ad' => true),
        //array('id' => 1009, 'cid' => 2, 'start' => getDT('-2 day +13 hour'), 'end' => getDT('-2 day +18 hour'), 'title' => 'Board meeting', 'loc' => 'ABC Inc.', 'rem' => 60),
        //array('id' => 1010, 'cid' => 3, 'start' => getDT('-2 day'), 'end' => getDT('+3 day -1 second'), 'title' => 'Jenny\'s final exams', 'ad' => true),
        //array('id' => 1011, 'cid' => 1, 'start' => getDT('+2 day +19 hour'), 'end' => getDT('+2 day +23 hour'), 'title' => 'Movie night', 'note' => 'Don\'t forget the tickets!', 'rem' => 60)
    
	//);
mysql_close($con);
echo json_encode($arr);

?>